# demo05_diy.py  自定义异常
def register():
    name = input("username: ")
    passwd = input("password: ")
    if len(passwd) >= 8:
        print(f"user: {name}, passwd: {passwd}")
    else:
        raise ValueError("密码长度不足8位!")
        # e = Exception("密码长度不足8位!")
        # e = ValueError("密码长度不足8位!")#1.创建异常
        # raise e # 2.抛出异常--raise
if __name__ == '__main__':
    register()
